package StudyCode.summary.mycollection;

import java.lang.reflect.Array;
import java.util.Iterator;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ConvertsAnArrayToAnIteratorOfObjects {
	public static Iterator<Object> toIteratorArray(final Object array) {
		final int length = Array.getLength(array);

		return new Iterator<Object>() {
			int index = 0;

			@Override
			public boolean hasNext() {
				return index < length;
			}

			@Override
			public Object next() {
				return Array.get(array, index++);
			}

			@Override
			public void remove() {
			}
		};
	}
}
